Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Sylvain 3 posts 23 karma points
    Oct 06, 2011 @ 14:56
    Sylvain
    0

    [beginner] Select a data with alias

    Hi,

    I'm very new with umbraco (and web developement).
    My goal is to select a data with the alias in a macro.

    This code works and display "12345" : <xsl:value-of select="$currentPage/number"/>

    But this code doesn't work and display nothing : <xsl:variable name="temp1" select="$currentPage/data[@alias='number']"/><xsl:value-of select="$temp1"/>

    Is there someone who can explain ?

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 06, 2011 @ 15:01
    Tom Fulton
    0

    Hi,

    The data [@alias='propertyAlias'] syntax is obsolete now.  It was the old XML Schema that Umbraco used to use, prior to version 4.5.

    There is no need to use this anymore, you instead refer to a property like in your first example ($currentPage/number).

    Check out this wiki page for more information and see the other pages/examples on the right:  4.5 XML Schema

    Hope this helps,
    Tom

  • Sylvain 3 posts 23 karma points
    Oct 06, 2011 @ 15:09
    Sylvain
    0

    Of course it helps Tom. Thank you.

    In fact, my goal is to select dynamically a data with the alias ( text macro parameters).

    How to do that now ?

     

    Edit : I will try that :

    select="$currentPage/* [name() = $myMacroParameter and not(@isDoc)]"/>
  • Tom Fulton 2030 posts 4998 karma points c-trib
    Oct 06, 2011 @ 15:12
    Tom Fulton
    0

    You can do that using the name() function, here's a simple example:

    <xsl:variable name="yourFieldAlias" select="'number'"/>  
    <!-- or from a macro parameter:  <xsl:variable name="yourFieldAlias" select="/macro/yourParam"/> -->

    <xsl:value-of select="$currentPage/* [not(@isDoc)][name() = $yourFieldAlias]"/>

    That should get you the same result as $currentPage/number

    -Tom

  • Sylvain 3 posts 23 karma points
    Oct 06, 2011 @ 15:15
    Sylvain
    0

    Thank you very much Tom. It seems easy now.

Please Sign in or register to post replies

Write your reply to:

Draft